package com.bjtu.douyin.config;

import com.bjtu.douyin.utils.ProtobufSerializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.google.protobuf.Message;

@Configuration
public class ProtobufSerializationConfig {

    @Bean
    public Jackson2ObjectMapperBuilderCustomizer protobufJacksonCustomizer() {
        return jacksonObjectMapperBuilder -> {
            SimpleModule protobufModule = new SimpleModule();
            protobufModule.addSerializer(Message.class, new ProtobufSerializer());
            jacksonObjectMapperBuilder.modules(protobufModule);
        };
    }
}
